<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: ActionView::Helpers::TextHelper</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">ActionView::Helpers::TextHelper</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../files/vendor/rails/actionpack/lib/action_view/helpers/text_helper_rb.html">
                vendor/rails/actionpack/lib/action_view/helpers/text_helper.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
The <a href="TextHelper.html">TextHelper</a> module provides a set of
methods for filtering, formatting and transforming strings, which can
reduce the amount of inline Ruby code in your views. These helper methods
extend ActionView making them callable within your template files.
</p>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M002132">auto_link</a>&nbsp;&nbsp;
      <a href="#M002122">concat</a>&nbsp;&nbsp;
      <a href="#M002134">current_cycle</a>&nbsp;&nbsp;
      <a href="#M002133">cycle</a>&nbsp;&nbsp;
      <a href="#M002125">excerpt</a>&nbsp;&nbsp;
      <a href="#M002124">highlight</a>&nbsp;&nbsp;
      <a href="#M002130">markdown</a>&nbsp;&nbsp;
      <a href="#M002126">pluralize</a>&nbsp;&nbsp;
      <a href="#M002135">reset_cycle</a>&nbsp;&nbsp;
      <a href="#M002131">simple_format</a>&nbsp;&nbsp;
      <a href="#M002128">textilize</a>&nbsp;&nbsp;
      <a href="#M002129">textilize_without_paragraph</a>&nbsp;&nbsp;
      <a href="#M002123">truncate</a>&nbsp;&nbsp;
      <a href="#M002127">word_wrap</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">


    <div id="constants-list">
      <h3 class="section-bar">Constants</h3>

      <div class="name-list">
        <table summary="Constants">
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">AUTO_LINK_RE</td>
          <td>=</td>
          <td class="context-item-value">%r{                         (                          # leading text                           &lt;\w+.*?&gt;|                # leading HTML tag, or                           [^=!:'&quot;/]|               # leading punctuation, or                           ^                        # beginning of line                         )                         (                           (?:https?://)|           # protocol spec, or                           (?:www\.)                # www.*                         )                         (                           [-\w]+                   # subdomain or domain                           (?:\.[-\w]+)*            # remaining subdomains or domain                           (?::\d+)?                # port                           (?:/(?:[~\w\+@%=\(\)-]|(?:[,.;:'][^\s$]))*)* # path                           (?:\?[\w\+@%&amp;=.;:-]+)?     # query string                           (?:\#[\w\-]*)?           # trailing anchor                         )                         ([[:punct:]]|&lt;|$|)       # trailing text                        }x unless const_defined?(:AUTO_LINK_RE)</td>
        </tr>
        </table>
      </div>
    </div>



      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M002132" class="method-detail">
        <a name="M002132"></a>

        <div class="method-heading">
          <a href="#M002132" class="method-signature">
          <span class="method-name">auto_link</span><span class="method-args">(text, *args, &amp;block)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Turns all URLs and e-mail addresses into clickable links. The
<tt>:link</tt> option will limit what should be linked. You can add HTML
attributes to the links using <tt>:href_options</tt>. Possible values for
<tt>:link</tt> are <tt>:all</tt> (default), <tt>:email_addresses</tt>, and
<tt>:urls</tt>. If a block is given, each URL and e-mail address is yielded
and the result is used as the link text.
</p>
<h4>Examples</h4>
<pre>
  auto_link(&quot;Go to http://www.rubyonrails.org and say hello to david@loudthinking.com&quot;)
  # =&gt; &quot;Go to &lt;a href=\&quot;http://www.rubyonrails.org\&quot;&gt;http://www.rubyonrails.org&lt;/a&gt; and
  #     say hello to &lt;a href=\&quot;mailto:david@loudthinking.com\&quot;&gt;david@loudthinking.com&lt;/a&gt;&quot;

  auto_link(&quot;Visit http://www.loudthinking.com/ or e-mail david@loudthinking.com&quot;, :link =&gt; :urls)
  # =&gt; &quot;Visit &lt;a href=\&quot;http://www.loudthinking.com/\&quot;&gt;http://www.loudthinking.com/&lt;/a&gt;
  #     or e-mail david@loudthinking.com&quot;

  auto_link(&quot;Visit http://www.loudthinking.com/ or e-mail david@loudthinking.com&quot;, :link =&gt; :email_addresses)
  # =&gt; &quot;Visit http://www.loudthinking.com/ or e-mail &lt;a href=\&quot;mailto:david@loudthinking.com\&quot;&gt;david@loudthinking.com&lt;/a&gt;&quot;

  post_body = &quot;Welcome to my new blog at http://www.myblog.com/.  Please e-mail me at me@email.com.&quot;
  auto_link(post_body, :href_options =&gt; { :target =&gt; '_blank' }) do |text|
    truncate(text, 15)
  end
  # =&gt; &quot;Welcome to my new blog at &lt;a href=\&quot;http://www.myblog.com/\&quot; target=\&quot;_blank\&quot;&gt;http://www.m...&lt;/a&gt;.
        Please e-mail me at &lt;a href=\&quot;mailto:me@email.com\&quot;&gt;me@email.com&lt;/a&gt;.&quot;
</pre>
<p>
You can still use <tt><a href="TextHelper.html#M002132">auto_link</a></tt>
with the old API that accepts the <tt>link</tt> as its optional second
parameter and the <tt>html_options</tt> hash as its optional third
parameter:
</p>
<pre>
  post_body = &quot;Welcome to my new blog at http://www.myblog.com/. Please e-mail me at me@email.com.&quot;
  auto_link(post_body, :urls)     # =&gt; Once upon\na time
  # =&gt; &quot;Welcome to my new blog at &lt;a href=\&quot;http://www.myblog.com/\&quot;&gt;http://www.myblog.com&lt;/a&gt;.
        Please e-mail me at me@email.com.&quot;

  auto_link(post_body, :all, :target =&gt; &quot;_blank&quot;)     # =&gt; Once upon\na time
  # =&gt; &quot;Welcome to my new blog at &lt;a href=\&quot;http://www.myblog.com/\&quot; target=\&quot;_blank\&quot;&gt;http://www.myblog.com&lt;/a&gt;.
        Please e-mail me at &lt;a href=\&quot;mailto:me@email.com\&quot;&gt;me@email.com&lt;/a&gt;.&quot;
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M002132-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M002132-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/helpers/text_helper.rb, line 384</span>
384:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">auto_link</span>(<span class="ruby-identifier">text</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)<span class="ruby-comment cmt">#link = :all, href_options = {}, &amp;block)</span>
385:         <span class="ruby-keyword kw">return</span> <span class="ruby-value str">''</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">text</span>.<span class="ruby-identifier">blank?</span>
386: 
387:         <span class="ruby-identifier">options</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">2</span> <span class="ruby-operator">?</span> {} <span class="ruby-operator">:</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">extract_options!</span> <span class="ruby-comment cmt"># this is necessary because the old auto_link API has a Hash as its last parameter</span>
388:         <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">empty?</span>
389:           <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:link</span>] = <span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">:all</span>
390:           <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:html</span>] = <span class="ruby-identifier">args</span>[<span class="ruby-value">1</span>] <span class="ruby-operator">||</span> {}
391:         <span class="ruby-keyword kw">end</span>
392:         <span class="ruby-identifier">options</span>.<span class="ruby-identifier">reverse_merge!</span>(<span class="ruby-identifier">:link</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">:all</span>, <span class="ruby-identifier">:html</span> =<span class="ruby-operator">&gt;</span> {})
393: 
394:         <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:link</span>].<span class="ruby-identifier">to_sym</span>
395:           <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:all</span>                         <span class="ruby-keyword kw">then</span> <span class="ruby-identifier">auto_link_email_addresses</span>(<span class="ruby-identifier">auto_link_urls</span>(<span class="ruby-identifier">text</span>, <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:html</span>], <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>), <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
396:           <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:email_addresses</span>             <span class="ruby-keyword kw">then</span> <span class="ruby-identifier">auto_link_email_addresses</span>(<span class="ruby-identifier">text</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
397:           <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:urls</span>                        <span class="ruby-keyword kw">then</span> <span class="ruby-identifier">auto_link_urls</span>(<span class="ruby-identifier">text</span>, <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:html</span>], <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
398:         <span class="ruby-keyword kw">end</span>
399:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M002122" class="method-detail">
        <a name="M002122"></a>

        <div class="method-heading">
          <a href="#M002122" class="method-signature">
          <span class="method-name">concat</span><span class="method-args">(string, unused_binding = nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
The preferred method of outputting text in your views is to use the &lt;%=
&quot;text&quot; %&gt; eRuby syntax. The regular <em>puts</em> and
<em>print</em> methods do not operate as expected in an eRuby code block.
If you absolutely must output text within a non-output code block (i.e.,
&lt;% %&gt;), you can use the <a href="TextHelper.html#M002122">concat</a>
method.
</p>
<h4>Examples</h4>
<pre>
  &lt;%
      concat &quot;hello&quot;
      # is the equivalent of &lt;%= &quot;hello&quot; %&gt;

      if (logged_in == true):
        concat &quot;Logged in!&quot;
      else
        concat link_to('login', :action =&gt; login)
      end
      # will either display &quot;Logged in!&quot; or a login link
  %&gt;
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M002122-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M002122-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/helpers/text_helper.rb, line 37</span>
37:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">concat</span>(<span class="ruby-identifier">string</span>, <span class="ruby-identifier">unused_binding</span> = <span class="ruby-keyword kw">nil</span>)
38:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">unused_binding</span>
39:           <span class="ruby-constant">ActiveSupport</span><span class="ruby-operator">::</span><span class="ruby-constant">Deprecation</span>.<span class="ruby-identifier">warn</span>(<span class="ruby-value str">&quot;The binding argument of #concat is no longer needed.  Please remove it from your views and helpers.&quot;</span>, <span class="ruby-identifier">caller</span>)
40:         <span class="ruby-keyword kw">end</span>
41: 
42:         <span class="ruby-identifier">output_buffer</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">string</span>
43:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M002134" class="method-detail">
        <a name="M002134"></a>

        <div class="method-heading">
          <a href="#M002134" class="method-signature">
          <span class="method-name">current_cycle</span><span class="method-args">(name = &quot;default&quot;)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns the current <a href="TextHelper.html#M002133">cycle</a> string
after a <a href="TextHelper.html#M002133">cycle</a> has been started.
Useful for complex table highlighing or any other design need which
requires the current <a href="TextHelper.html#M002133">cycle</a> string in
more than one place.
</p>
<h4>Example</h4>
<pre>
  # Alternate background colors
  @items = [1,2,3,4]
  &lt;% @items.each do |item| %&gt;
    &lt;div style=&quot;background-color:&lt;%= cycle(&quot;red&quot;,&quot;white&quot;,&quot;blue&quot;) %&gt;&quot;&gt;
      &lt;span style=&quot;background-color:&lt;%= current_cycle %&gt;&quot;&gt;&lt;%= item %&gt;&lt;/span&gt;
    &lt;/div&gt;
  &lt;% end %&gt;
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M002134-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M002134-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/helpers/text_helper.rb, line 467</span>
467:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">current_cycle</span>(<span class="ruby-identifier">name</span> = <span class="ruby-value str">&quot;default&quot;</span>)
468:         <span class="ruby-identifier">cycle</span> = <span class="ruby-identifier">get_cycle</span>(<span class="ruby-identifier">name</span>)
469:         <span class="ruby-identifier">cycle</span>.<span class="ruby-identifier">current_value</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">cycle</span>.<span class="ruby-identifier">nil?</span>
470:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M002133" class="method-detail">
        <a name="M002133"></a>

        <div class="method-heading">
          <a href="#M002133" class="method-signature">
          <span class="method-name">cycle</span><span class="method-args">(first_value, *values)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Creates a Cycle object whose <em>to_s</em> method cycles through elements
of an array every time it is called. This can be used for example, to
alternate classes for table rows. You can use named cycles to allow nesting
in loops. Passing a Hash as the last parameter with a <tt>:name</tt> key
will create a named <a href="TextHelper.html#M002133">cycle</a>. The
default name for a <a href="TextHelper.html#M002133">cycle</a> without a
+:name+ key is <tt>&quot;default&quot;</tt>. You can manually reset a <a
href="TextHelper.html#M002133">cycle</a> by calling <a
href="TextHelper.html#M002135">reset_cycle</a> and passing the name of the
<a href="TextHelper.html#M002133">cycle</a>. The current <a
href="TextHelper.html#M002133">cycle</a> string can be obtained anytime
using the <a href="TextHelper.html#M002134">current_cycle</a> method.
</p>
<h4>Examples</h4>
<pre>
  # Alternate CSS classes for even and odd numbers...
  @items = [1,2,3,4]
  &lt;table&gt;
  &lt;% @items.each do |item| %&gt;
    &lt;tr class=&quot;&lt;%= cycle(&quot;even&quot;, &quot;odd&quot;) -%&gt;&quot;&gt;
      &lt;td&gt;item&lt;/td&gt;
    &lt;/tr&gt;
  &lt;% end %&gt;
  &lt;/table&gt;

  # Cycle CSS classes for rows, and text colors for values within each row
  @items = x = [{:first =&gt; 'Robert', :middle =&gt; 'Daniel', :last =&gt; 'James'},
               {:first =&gt; 'Emily', :middle =&gt; 'Shannon', :maiden =&gt; 'Pike', :last =&gt; 'Hicks'},
              {:first =&gt; 'June', :middle =&gt; 'Dae', :last =&gt; 'Jones'}]
  &lt;% @items.each do |item| %&gt;
    &lt;tr class=&quot;&lt;%= cycle(&quot;even&quot;, &quot;odd&quot;, :name =&gt; &quot;row_class&quot;) -%&gt;&quot;&gt;
      &lt;td&gt;
        &lt;% item.values.each do |value| %&gt;
          &lt;%# Create a named cycle &quot;colors&quot; %&gt;
          &lt;span style=&quot;color:&lt;%= cycle(&quot;red&quot;, &quot;green&quot;, &quot;blue&quot;, :name =&gt; &quot;colors&quot;) -%&gt;&quot;&gt;
            &lt;%= value %&gt;
          &lt;/span&gt;
        &lt;% end %&gt;
        &lt;% reset_cycle(&quot;colors&quot;) %&gt;
      &lt;/td&gt;
   &lt;/tr&gt;
 &lt;% end %&gt;
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M002133-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M002133-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/helpers/text_helper.rb, line 439</span>
439:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cycle</span>(<span class="ruby-identifier">first_value</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">values</span>)
440:         <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">values</span>.<span class="ruby-identifier">last</span>.<span class="ruby-identifier">instance_of?</span> <span class="ruby-constant">Hash</span>)
441:           <span class="ruby-identifier">params</span> = <span class="ruby-identifier">values</span>.<span class="ruby-identifier">pop</span>
442:           <span class="ruby-identifier">name</span> = <span class="ruby-identifier">params</span>[<span class="ruby-identifier">:name</span>]
443:         <span class="ruby-keyword kw">else</span>
444:           <span class="ruby-identifier">name</span> = <span class="ruby-value str">&quot;default&quot;</span>
445:         <span class="ruby-keyword kw">end</span>
446:         <span class="ruby-identifier">values</span>.<span class="ruby-identifier">unshift</span>(<span class="ruby-identifier">first_value</span>)
447: 
448:         <span class="ruby-identifier">cycle</span> = <span class="ruby-identifier">get_cycle</span>(<span class="ruby-identifier">name</span>)
449:         <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">cycle</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">cycle</span>.<span class="ruby-identifier">values</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">values</span>)
450:           <span class="ruby-identifier">cycle</span> = <span class="ruby-identifier">set_cycle</span>(<span class="ruby-identifier">name</span>, <span class="ruby-constant">Cycle</span>.<span class="ruby-identifier">new</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">values</span>))
451:         <span class="ruby-keyword kw">end</span>
452:         <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">cycle</span>.<span class="ruby-identifier">to_s</span>
453:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M002125" class="method-detail">
        <a name="M002125"></a>

        <div class="method-heading">
          <a href="#M002125" class="method-signature">
          <span class="method-name">excerpt</span><span class="method-args">(text, phrase, *args)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Extracts an <a href="TextHelper.html#M002125">excerpt</a> from
<tt>text</tt> that matches the first instance of <tt>phrase</tt>. The
<tt>:radius</tt> option expands the <a
href="TextHelper.html#M002125">excerpt</a> on each side of the first
occurrence of <tt>phrase</tt> by the number of characters defined in
<tt>:radius</tt> (which defaults to 100). If the <a
href="TextHelper.html#M002125">excerpt</a> radius overflows the beginning
or end of the <tt>text</tt>, then the <tt>:omission</tt> option (which
defaults to &quot;&#8230;&quot;) will be prepended/appended accordingly.
The resulting string will be stripped in any case. If the <tt>phrase</tt>
isn&#8216;t found, nil is returned.
</p>
<h4>Examples</h4>
<pre>
  excerpt('This is an example', 'an', :radius =&gt; 5)
  # =&gt; ...s is an exam...

  excerpt('This is an example', 'is', :radius =&gt; 5)
  # =&gt; This is a...

  excerpt('This is an example', 'is')
  # =&gt; This is an example

  excerpt('This next thing is an example', 'ex', :radius =&gt; 2)
  # =&gt; ...next...

  excerpt('This is also an example', 'an', :radius =&gt; 8, :omission =&gt; '&lt;chop&gt; ')
  # =&gt; &lt;chop&gt; is also an example
</pre>
<p>
You can still use <tt><a href="TextHelper.html#M002125">excerpt</a></tt>
with the old API that accepts the <tt>radius</tt> as its optional third and
the <tt>ellipsis</tt> as its optional forth parameter:
</p>
<pre>
  excerpt('This is an example', 'an', 5)                   # =&gt; ...s is an exam...
  excerpt('This is also an example', 'an', 8, '&lt;chop&gt; ')   # =&gt; &lt;chop&gt; is also an example
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M002125-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M002125-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/helpers/text_helper.rb, line 151</span>
151:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">excerpt</span>(<span class="ruby-identifier">text</span>, <span class="ruby-identifier">phrase</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
152:         <span class="ruby-identifier">options</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">extract_options!</span>
153:         <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">empty?</span>
154:           <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:radius</span>] = <span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">||</span> <span class="ruby-value">100</span>
155:           <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:omission</span>] = <span class="ruby-identifier">args</span>[<span class="ruby-value">1</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">&quot;...&quot;</span>
156:         <span class="ruby-keyword kw">end</span>
157:         <span class="ruby-identifier">options</span>.<span class="ruby-identifier">reverse_merge!</span>(<span class="ruby-identifier">:radius</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">100</span>, <span class="ruby-identifier">:omission</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;...&quot;</span>)
158: 
159:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">text</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">phrase</span>
160:           <span class="ruby-identifier">phrase</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">escape</span>(<span class="ruby-identifier">phrase</span>)
161: 
162:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">found_pos</span> = <span class="ruby-identifier">text</span>.<span class="ruby-identifier">mb_chars</span> <span class="ruby-operator">=~</span> <span class="ruby-node">/(#{phrase})/i</span>
163:             <span class="ruby-identifier">start_pos</span> = [ <span class="ruby-identifier">found_pos</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:radius</span>], <span class="ruby-value">0</span> ].<span class="ruby-identifier">max</span>
164:             <span class="ruby-identifier">end_pos</span>   = [ [ <span class="ruby-identifier">found_pos</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">phrase</span>.<span class="ruby-identifier">mb_chars</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:radius</span>] <span class="ruby-operator">-</span> <span class="ruby-value">1</span>, <span class="ruby-value">0</span>].<span class="ruby-identifier">max</span>, <span class="ruby-identifier">text</span>.<span class="ruby-identifier">mb_chars</span>.<span class="ruby-identifier">length</span> ].<span class="ruby-identifier">min</span>
165: 
166:             <span class="ruby-identifier">prefix</span>  = <span class="ruby-identifier">start_pos</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:omission</span>] <span class="ruby-operator">:</span> <span class="ruby-value str">&quot;&quot;</span>
167:             <span class="ruby-identifier">postfix</span> = <span class="ruby-identifier">end_pos</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">text</span>.<span class="ruby-identifier">mb_chars</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:omission</span>] <span class="ruby-operator">:</span> <span class="ruby-value str">&quot;&quot;</span>
168: 
169:             <span class="ruby-identifier">prefix</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">text</span>.<span class="ruby-identifier">mb_chars</span>[<span class="ruby-identifier">start_pos</span><span class="ruby-operator">..</span><span class="ruby-identifier">end_pos</span>].<span class="ruby-identifier">strip</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">postfix</span>
170:           <span class="ruby-keyword kw">else</span>
171:             <span class="ruby-keyword kw">nil</span>
172:           <span class="ruby-keyword kw">end</span>
173:         <span class="ruby-keyword kw">end</span>
174:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M002124" class="method-detail">
        <a name="M002124"></a>

        <div class="method-heading">
          <a href="#M002124" class="method-signature">
          <span class="method-name">highlight</span><span class="method-args">(text, phrases, *args)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Highlights one or more <tt>phrases</tt> everywhere in <tt>text</tt> by
inserting it into a <tt>:highlighter</tt> string. The highlighter can be
specialized by passing <tt>:highlighter</tt> as a single-quoted string with
\1 where the phrase is to be inserted (defaults to &#8217;&lt;strong
class=&quot;<a
href="TextHelper.html#M002124">highlight</a>&quot;&gt;\1&lt;/strong&gt;&#8217;)
</p>
<h4>Examples</h4>
<pre>
  highlight('You searched for: rails', 'rails')
  # =&gt; You searched for: &lt;strong class=&quot;highlight&quot;&gt;rails&lt;/strong&gt;

  highlight('You searched for: ruby, rails, dhh', 'actionpack')
  # =&gt; You searched for: ruby, rails, dhh

  highlight('You searched for: rails', ['for', 'rails'], :highlighter =&gt; '&lt;em&gt;\1&lt;/em&gt;')
  # =&gt; You searched &lt;em&gt;for&lt;/em&gt;: &lt;em&gt;rails&lt;/em&gt;

  highlight('You searched for: rails', 'rails', :highlighter =&gt; '&lt;a href=&quot;search?q=\1&quot;&gt;\1&lt;/a&gt;')
  # =&gt; You searched for: &lt;a href=&quot;search?q=rails&quot;&gt;rails&lt;/a&gt;
</pre>
<p>
You can still use <tt><a href="TextHelper.html#M002124">highlight</a></tt>
with the old API that accepts the <tt>highlighter</tt> as its optional
third parameter:
</p>
<pre>
  highlight('You searched for: rails', 'rails', '&lt;a href=&quot;search?q=\1&quot;&gt;\1&lt;/a&gt;')     # =&gt; You searched for: &lt;a href=&quot;search?q=rails&quot;&gt;rails&lt;/a&gt;
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M002124-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M002124-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/helpers/text_helper.rb, line 109</span>
109:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">highlight</span>(<span class="ruby-identifier">text</span>, <span class="ruby-identifier">phrases</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
110:         <span class="ruby-identifier">options</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">extract_options!</span>
111:         <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">empty?</span>
112:           <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:highlighter</span>] = <span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">'&lt;strong class=&quot;highlight&quot;&gt;\1&lt;/strong&gt;'</span>
113:         <span class="ruby-keyword kw">end</span>
114:         <span class="ruby-identifier">options</span>.<span class="ruby-identifier">reverse_merge!</span>(<span class="ruby-identifier">:highlighter</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'&lt;strong class=&quot;highlight&quot;&gt;\1&lt;/strong&gt;'</span>)
115: 
116:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">text</span>.<span class="ruby-identifier">blank?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">phrases</span>.<span class="ruby-identifier">blank?</span>
117:           <span class="ruby-identifier">text</span>
118:         <span class="ruby-keyword kw">else</span>
119:           <span class="ruby-identifier">match</span> = <span class="ruby-constant">Array</span>(<span class="ruby-identifier">phrases</span>).<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span> <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">escape</span>(<span class="ruby-identifier">p</span>) }.<span class="ruby-identifier">join</span>(<span class="ruby-value str">'|'</span>)
120:           <span class="ruby-identifier">text</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-node">/(#{match})/i</span>, <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:highlighter</span>])
121:         <span class="ruby-keyword kw">end</span>
122:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M002130" class="method-detail">
        <a name="M002130"></a>

        <div class="method-heading">
          <a href="#M002130" class="method-signature">
          <span class="method-name">markdown</span><span class="method-args">(text)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns the text with all the Markdown codes turned into HTML tags.
<em>This method is only available if <a
href="http://www.deveiate.org/projects/BlueCloth">BlueCloth</a> is
available</em>.
</p>
<h4>Examples</h4>
<pre>
  markdown(&quot;We are using __Markdown__ now!&quot;)
  # =&gt; &quot;&lt;p&gt;We are using &lt;strong&gt;Markdown&lt;/strong&gt; now!&lt;/p&gt;&quot;

  markdown(&quot;We like to _write_ `code`, not just _read_ it!&quot;)
  # =&gt; &quot;&lt;p&gt;We like to &lt;em&gt;write&lt;/em&gt; &lt;code&gt;code&lt;/code&gt;, not just &lt;em&gt;read&lt;/em&gt; it!&lt;/p&gt;&quot;

  markdown(&quot;The [Markdown website](http://daringfireball.net/projects/markdown/) has more information.&quot;)
  # =&gt; &quot;&lt;p&gt;The &lt;a href=&quot;http://daringfireball.net/projects/markdown/&quot;&gt;Markdown website&lt;/a&gt;
  #     has more information.&lt;/p&gt;&quot;

  markdown('![The ROR logo](http://rubyonrails.com/images/rails.png &quot;Ruby on Rails&quot;)')
  # =&gt; '&lt;p&gt;&lt;img src=&quot;http://rubyonrails.com/images/rails.png&quot; alt=&quot;The ROR logo&quot; title=&quot;Ruby on Rails&quot; /&gt;&lt;/p&gt;'
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M002130-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M002130-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/helpers/text_helper.rb, line 309</span>
309:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">markdown</span>(<span class="ruby-identifier">text</span>)
310:           <span class="ruby-identifier">text</span>.<span class="ruby-identifier">blank?</span> <span class="ruby-value">? </span><span class="ruby-value str">&quot;&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-constant">BlueCloth</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">text</span>).<span class="ruby-identifier">to_html</span>
311:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M002126" class="method-detail">
        <a name="M002126"></a>

        <div class="method-heading">
          <a href="#M002126" class="method-signature">
          <span class="method-name">pluralize</span><span class="method-args">(count, singular, plural = nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Attempts to <a href="TextHelper.html#M002126">pluralize</a> the
<tt>singular</tt> word unless <tt>count</tt> is 1. If <tt>plural</tt> is
supplied, it will use that when count is &gt; 1, otherwise it will use the
Inflector to determine the plural form
</p>
<h4>Examples</h4>
<pre>
  pluralize(1, 'person')
  # =&gt; 1 person

  pluralize(2, 'person')
  # =&gt; 2 people

  pluralize(3, 'person', 'users')
  # =&gt; 3 users

  pluralize(0, 'person')
  # =&gt; 0 people
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M002126-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M002126-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/helpers/text_helper.rb, line 192</span>
192:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">pluralize</span>(<span class="ruby-identifier">count</span>, <span class="ruby-identifier">singular</span>, <span class="ruby-identifier">plural</span> = <span class="ruby-keyword kw">nil</span>)
193:         <span class="ruby-node">&quot;#{count || 0} &quot;</span> <span class="ruby-operator">+</span> ((<span class="ruby-identifier">count</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">count</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'1'</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">singular</span> <span class="ruby-operator">:</span> (<span class="ruby-identifier">plural</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">singular</span>.<span class="ruby-identifier">pluralize</span>))
194:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M002135" class="method-detail">
        <a name="M002135"></a>

        <div class="method-heading">
          <a href="#M002135" class="method-signature">
          <span class="method-name">reset_cycle</span><span class="method-args">(name = &quot;default&quot;)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Resets a <a href="TextHelper.html#M002133">cycle</a> so that it starts from
the first element the next time it is called. Pass in <tt>name</tt> to
reset a named <a href="TextHelper.html#M002133">cycle</a>.
</p>
<h4>Example</h4>
<pre>
  # Alternate CSS classes for even and odd numbers...
  @items = [[1,2,3,4], [5,6,3], [3,4,5,6,7,4]]
  &lt;table&gt;
  &lt;% @items.each do |item| %&gt;
    &lt;tr class=&quot;&lt;%= cycle(&quot;even&quot;, &quot;odd&quot;) -%&gt;&quot;&gt;
        &lt;% item.each do |value| %&gt;
          &lt;span style=&quot;color:&lt;%= cycle(&quot;#333&quot;, &quot;#666&quot;, &quot;#999&quot;, :name =&gt; &quot;colors&quot;) -%&gt;&quot;&gt;
            &lt;%= value %&gt;
          &lt;/span&gt;
        &lt;% end %&gt;

        &lt;% reset_cycle(&quot;colors&quot;) %&gt;
    &lt;/tr&gt;
  &lt;% end %&gt;
  &lt;/table&gt;
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M002135-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M002135-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/helpers/text_helper.rb, line 491</span>
491:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reset_cycle</span>(<span class="ruby-identifier">name</span> = <span class="ruby-value str">&quot;default&quot;</span>)
492:         <span class="ruby-identifier">cycle</span> = <span class="ruby-identifier">get_cycle</span>(<span class="ruby-identifier">name</span>)
493:         <span class="ruby-identifier">cycle</span>.<span class="ruby-identifier">reset</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">cycle</span>.<span class="ruby-identifier">nil?</span>
494:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M002131" class="method-detail">
        <a name="M002131"></a>

        <div class="method-heading">
          <a href="#M002131" class="method-signature">
          <span class="method-name">simple_format</span><span class="method-args">(text, html_options={})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns <tt>text</tt> transformed into HTML using simple formatting rules.
Two or more consecutive newlines(<tt>\n\n</tt>) are considered as a
paragraph and wrapped in <tt>&lt;p&gt;</tt> tags. One newline (<tt>\n</tt>)
is considered as a linebreak and a <tt>&lt;br /&gt;</tt> tag is appended.
This method does not remove the newlines from the <tt>text</tt>.
</p>
<p>
You can pass any HTML attributes into <tt>html_options</tt>. These will be
added to all created paragraphs.
</p>
<h4>Examples</h4>
<pre>
  my_text = &quot;Here is some basic text...\n...with a line break.&quot;

  simple_format(my_text)
  # =&gt; &quot;&lt;p&gt;Here is some basic text...\n&lt;br /&gt;...with a line break.&lt;/p&gt;&quot;

  more_text = &quot;We want to put a paragraph...\n\n...right there.&quot;

  simple_format(more_text)
  # =&gt; &quot;&lt;p&gt;We want to put a paragraph...&lt;/p&gt;\n\n&lt;p&gt;...right there.&lt;/p&gt;&quot;

  simple_format(&quot;Look ma! A class!&quot;, :class =&gt; 'description')
  # =&gt; &quot;&lt;p class='description'&gt;Look ma! A class!&lt;/p&gt;&quot;
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M002131-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M002131-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/helpers/text_helper.rb, line 337</span>
337:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">simple_format</span>(<span class="ruby-identifier">text</span>, <span class="ruby-identifier">html_options</span>={})
338:         <span class="ruby-identifier">start_tag</span> = <span class="ruby-identifier">tag</span>(<span class="ruby-value str">'p'</span>, <span class="ruby-identifier">html_options</span>, <span class="ruby-keyword kw">true</span>)
339:         <span class="ruby-identifier">text</span> = <span class="ruby-identifier">text</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">dup</span>
340:         <span class="ruby-identifier">text</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/\r\n?/</span>, <span class="ruby-value str">&quot;\n&quot;</span>)                    <span class="ruby-comment cmt"># \r\n and \r -&gt; \n</span>
341:         <span class="ruby-identifier">text</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/\n\n+/</span>, <span class="ruby-node">&quot;&lt;/p&gt;\n\n#{start_tag}&quot;</span>)  <span class="ruby-comment cmt"># 2+ newline  -&gt; paragraph</span>
342:         <span class="ruby-identifier">text</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/([^\n]\n)(?=[^\n])/</span>, <span class="ruby-value str">'\1&lt;br /&gt;'</span>) <span class="ruby-comment cmt"># 1 newline   -&gt; br</span>
343:         <span class="ruby-identifier">text</span>.<span class="ruby-identifier">insert</span> <span class="ruby-value">0</span>, <span class="ruby-identifier">start_tag</span>
344:         <span class="ruby-identifier">text</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;&lt;/p&gt;&quot;</span>
345:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M002128" class="method-detail">
        <a name="M002128"></a>

        <div class="method-heading">
          <a href="#M002128" class="method-signature">
          <span class="method-name">textilize</span><span class="method-args">(text)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns the text with all the <a
href="http://www.textism.com/tools/textile">Textile</a> codes turned into
HTML tags.
</p>
<p>
You can learn more about Textile&#8216;s syntax at its <a
href="http://www.textism.com/tools/textile">website</a>. <em>This method is
only available if <a
href="http://whytheluckystiff.net/ruby/redcloth/">RedCloth</a> is
available</em>.
</p>
<h4>Examples</h4>
<pre>
  textilize(&quot;*This is Textile!*  Rejoice!&quot;)
  # =&gt; &quot;&lt;p&gt;&lt;strong&gt;This is Textile!&lt;/strong&gt;  Rejoice!&lt;/p&gt;&quot;

  textilize(&quot;I _love_ ROR(Ruby on Rails)!&quot;)
  # =&gt; &quot;&lt;p&gt;I &lt;em&gt;love&lt;/em&gt; &lt;acronym title=&quot;Ruby on Rails&quot;&gt;ROR&lt;/acronym&gt;!&lt;/p&gt;&quot;

  textilize(&quot;h2. Textile makes markup -easy- simple!&quot;)
  # =&gt; &quot;&lt;h2&gt;Textile makes markup &lt;del&gt;easy&lt;/del&gt; simple!&lt;/h2&gt;&quot;

  textilize(&quot;Visit the Rails website &quot;here&quot;:http://www.rubyonrails.org/.)
  # =&gt; &quot;&lt;p&gt;Visit the Rails website &lt;a href=&quot;http://www.rubyonrails.org/&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&quot;
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M002128-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M002128-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/helpers/text_helper.rb, line 250</span>
250:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">textilize</span>(<span class="ruby-identifier">text</span>)
251:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">text</span>.<span class="ruby-identifier">blank?</span>
252:             <span class="ruby-value str">&quot;&quot;</span>
253:           <span class="ruby-keyword kw">else</span>
254:             <span class="ruby-identifier">textilized</span> = <span class="ruby-constant">RedCloth</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">text</span>, [ <span class="ruby-identifier">:hard_breaks</span> ])
255:             <span class="ruby-identifier">textilized</span>.<span class="ruby-identifier">hard_breaks</span> = <span class="ruby-keyword kw">true</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">textilized</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:hard_breaks=</span>)
256:             <span class="ruby-identifier">textilized</span>.<span class="ruby-identifier">to_html</span>
257:           <span class="ruby-keyword kw">end</span>
258:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M002129" class="method-detail">
        <a name="M002129"></a>

        <div class="method-heading">
          <a href="#M002129" class="method-signature">
          <span class="method-name">textilize_without_paragraph</span><span class="method-args">(text)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns the text with all the Textile codes turned into HTML tags, but
without the bounding &lt;p&gt; tag that RedCloth adds.
</p>
<p>
You can learn more about Textile&#8216;s syntax at its <a
href="http://www.textism.com/tools/textile">website</a>. <em>This method is
only available if <a
href="http://whytheluckystiff.net/ruby/redcloth/">RedCloth</a> is
available</em>.
</p>
<h4>Examples</h4>
<pre>
  textilize_without_paragraph(&quot;*This is Textile!*  Rejoice!&quot;)
  # =&gt; &quot;&lt;strong&gt;This is Textile!&lt;/strong&gt;  Rejoice!&quot;

  textilize_without_paragraph(&quot;I _love_ ROR(Ruby on Rails)!&quot;)
  # =&gt; &quot;I &lt;em&gt;love&lt;/em&gt; &lt;acronym title=&quot;Ruby on Rails&quot;&gt;ROR&lt;/acronym&gt;!&quot;

  textilize_without_paragraph(&quot;h2. Textile makes markup -easy- simple!&quot;)
  # =&gt; &quot;&lt;h2&gt;Textile makes markup &lt;del&gt;easy&lt;/del&gt; simple!&lt;/h2&gt;&quot;

  textilize_without_paragraph(&quot;Visit the Rails website &quot;here&quot;:http://www.rubyonrails.org/.)
  # =&gt; &quot;Visit the Rails website &lt;a href=&quot;http://www.rubyonrails.org/&quot;&gt;here&lt;/a&gt;.&quot;
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M002129-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M002129-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/helpers/text_helper.rb, line 279</span>
279:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">textilize_without_paragraph</span>(<span class="ruby-identifier">text</span>)
280:           <span class="ruby-identifier">textiled</span> = <span class="ruby-identifier">textilize</span>(<span class="ruby-identifier">text</span>)
281:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">textiled</span>[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-value">2</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;&lt;p&gt;&quot;</span> <span class="ruby-keyword kw">then</span> <span class="ruby-identifier">textiled</span> = <span class="ruby-identifier">textiled</span>[<span class="ruby-value">3</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>] <span class="ruby-keyword kw">end</span>
282:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">textiled</span>[<span class="ruby-value">-4</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;&lt;/p&gt;&quot;</span> <span class="ruby-keyword kw">then</span> <span class="ruby-identifier">textiled</span> = <span class="ruby-identifier">textiled</span>[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-value">-5</span>] <span class="ruby-keyword kw">end</span>
283:           <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">textiled</span>
284:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M002123" class="method-detail">
        <a name="M002123"></a>

        <div class="method-heading">
          <a href="#M002123" class="method-signature">
          <span class="method-name">truncate</span><span class="method-args">(text, *args)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Truncates a given <tt>text</tt> after a given <tt>:length</tt> if
<tt>text</tt> is longer than <tt>:length</tt> (defaults to 30). The last
characters will be replaced with the <tt>:omission</tt> (defaults to
&quot;&#8230;&quot;).
</p>
<h4>Examples</h4>
<pre>
  truncate(&quot;Once upon a time in a world far far away&quot;)
  # =&gt; Once upon a time in a world f...

  truncate(&quot;Once upon a time in a world far far away&quot;, :length =&gt; 14)
  # =&gt; Once upon a...

  truncate(&quot;And they found that many people were sleeping better.&quot;, :length =&gt; 25, &quot;(clipped)&quot;)
  # =&gt; And they found that many (clipped)

  truncate(&quot;And they found that many people were sleeping better.&quot;, :omission =&gt; &quot;... (continued)&quot;, :length =&gt; 15)
  # =&gt; And they found... (continued)
</pre>
<p>
You can still use <tt><a href="TextHelper.html#M002123">truncate</a></tt>
with the old API that accepts the <tt>length</tt> as its optional second
and the <tt>ellipsis</tt> as its optional third parameter:
</p>
<pre>
  truncate(&quot;Once upon a time in a world far far away&quot;, 14)
  # =&gt; Once upon a time in a world f...

  truncate(&quot;And they found that many people were sleeping better.&quot;, 15, &quot;... (continued)&quot;)
  # =&gt; And they found... (continued)
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M002123-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M002123-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/helpers/text_helper.rb, line 70</span>
70:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">truncate</span>(<span class="ruby-identifier">text</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
71:         <span class="ruby-identifier">options</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">extract_options!</span>
72:         <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">empty?</span>
73:           <span class="ruby-constant">ActiveSupport</span><span class="ruby-operator">::</span><span class="ruby-constant">Deprecation</span>.<span class="ruby-identifier">warn</span>(<span class="ruby-value str">'truncate takes an option hash instead of separate '</span> <span class="ruby-operator">+</span>
74:             <span class="ruby-value str">'length and omission arguments'</span>, <span class="ruby-identifier">caller</span>)
75: 
76:           <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:length</span>] = <span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">||</span> <span class="ruby-value">30</span>
77:           <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:omission</span>] = <span class="ruby-identifier">args</span>[<span class="ruby-value">1</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">&quot;...&quot;</span>
78:         <span class="ruby-keyword kw">end</span>
79:         <span class="ruby-identifier">options</span>.<span class="ruby-identifier">reverse_merge!</span>(<span class="ruby-identifier">:length</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">30</span>, <span class="ruby-identifier">:omission</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;...&quot;</span>)
80: 
81:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">text</span>
82:           <span class="ruby-identifier">l</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:length</span>] <span class="ruby-operator">-</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:omission</span>].<span class="ruby-identifier">mb_chars</span>.<span class="ruby-identifier">length</span>
83:           <span class="ruby-identifier">chars</span> = <span class="ruby-identifier">text</span>.<span class="ruby-identifier">mb_chars</span>
84:           (<span class="ruby-identifier">chars</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">&gt;</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:length</span>] <span class="ruby-operator">?</span> <span class="ruby-identifier">chars</span>[<span class="ruby-value">0</span><span class="ruby-operator">...</span><span class="ruby-identifier">l</span>] <span class="ruby-operator">+</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:omission</span>] <span class="ruby-operator">:</span> <span class="ruby-identifier">text</span>).<span class="ruby-identifier">to_s</span>
85:         <span class="ruby-keyword kw">end</span>
86:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M002127" class="method-detail">
        <a name="M002127"></a>

        <div class="method-heading">
          <a href="#M002127" class="method-signature">
          <span class="method-name">word_wrap</span><span class="method-args">(text, *args)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Wraps the <tt>text</tt> into lines no longer than <tt>line_width</tt>
width. This method breaks on the first whitespace character that does not
exceed <tt>line_width</tt> (which is 80 by default).
</p>
<h4>Examples</h4>
<pre>
  word_wrap('Once upon a time')
  # =&gt; Once upon a time

  word_wrap('Once upon a time, in a kingdom called Far Far Away, a king fell ill, and finding a successor to the throne turned out to be more trouble than anyone could have imagined...')
  # =&gt; Once upon a time, in a kingdom called Far Far Away, a king fell ill, and finding\n a successor to the throne turned out to be more trouble than anyone could have\n imagined...

  word_wrap('Once upon a time', :line_width =&gt; 8)
  # =&gt; Once upon\na time

  word_wrap('Once upon a time', :line_width =&gt; 1)
  # =&gt; Once\nupon\na\ntime
</pre>
<p>
You can still use <tt><a href="TextHelper.html#M002127">word_wrap</a></tt>
with the old API that accepts the <tt>line_width</tt> as its optional
second parameter:
</p>
<pre>
  word_wrap('Once upon a time', 8)     # =&gt; Once upon\na time
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M002127-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M002127-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/helpers/text_helper.rb, line 217</span>
217:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">word_wrap</span>(<span class="ruby-identifier">text</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
218:         <span class="ruby-identifier">options</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">extract_options!</span>
219:         <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">blank?</span>
220:           <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:line_width</span>] = <span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">||</span> <span class="ruby-value">80</span>
221:         <span class="ruby-keyword kw">end</span>
222:         <span class="ruby-identifier">options</span>.<span class="ruby-identifier">reverse_merge!</span>(<span class="ruby-identifier">:line_width</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">80</span>)
223: 
224:         <span class="ruby-identifier">text</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">&quot;\n&quot;</span>).<span class="ruby-identifier">collect</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span>
225:           <span class="ruby-identifier">line</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">&gt;</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:line_width</span>] <span class="ruby-operator">?</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-node">/(.{1,#{options[:line_width]}})(\s+|$)/</span>, <span class="ruby-value str">&quot;\\1\n&quot;</span>).<span class="ruby-identifier">strip</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">line</span>
226:         <span class="ruby-keyword kw">end</span> <span class="ruby-operator">*</span> <span class="ruby-value str">&quot;\n&quot;</span>
227:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>